<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<script type="text/javascript">
    var fromgrid;
    $(function() {
        var  url='/insfrom/insfromListByWhere?';
        url=url+'eqtypeid='+'${eqtypeid}'+'&eqorgid='+'${eqorgid}'+'&departmentid='+'${departmentid}';
        console.log(url);
        fromgrid =  $('#insfromgridadd').datagrid({
            url : url,
            idField : 'id',
            //url : 'content.json',
            title : ' 设备列表',
            iconCls : 'icon-search',
            nowrap : true,
            striped: true,
            rownumbers : true,
            frozenColumns : [ [ {
                title : 'id',
                field : 'id',
                hidden : true
            } ] ],
            columns : [[
                {
                    field : 'inspectionitemname',
                    title : '巡查项目',
                    sortable : true,


                },
                {
                    field : 'inspectioncontent',
                    title : '巡查内容 ',
                    sortable : true,


                }


            ]],



        });

        $('#roleGrantForm').form({
            url : '${path }/role/grant',
            onSubmit : function() {
                progressLoad();
                var isValid = $(this).form('validate');
                if (!isValid) {
                    progressClose();
                }
                var checknodes = resourceTree.tree('getChecked');
                var ids = [];
                if (checknodes && checknodes.length > 0) {
                    for ( var i = 0; i < checknodes.length; i++) {
                        ids.push(checknodes[i].id);
                    }
                }
                $('#resourceIds').val(ids);
                return isValid;
            },
            success : function(result) {
                progressClose();
                result = $.parseJSON(result);
                if (result.success) {
                    parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
                    parent.$.modalDialog.handler.dialog('close');
                } else {
                    parent.$.messager.alert('错误', result.msg, 'error');
                }
            }
        });
    });

    function checkAll() {
        var nodes = resourceTree.tree('getChecked', 'unchecked');
        if (nodes && nodes.length > 0) {
            for ( var i = 0; i < nodes.length; i++) {
                resourceTree.tree('check', nodes[i].target);
            }
        }
    }
    function uncheckAll() {
        var nodes = resourceTree.tree('getChecked');
        if (nodes && nodes.length > 0) {
            for ( var i = 0; i < nodes.length; i++) {
                resourceTree.tree('uncheck', nodes[i].target);
            }
        }
    }
    function checkInverse() {
        var unchecknodes = resourceTree.tree('getChecked', 'unchecked');
        var checknodes = resourceTree.tree('getChecked');
        if (unchecknodes && unchecknodes.length > 0) {
            for ( var i = 0; i < unchecknodes.length; i++) {
                resourceTree.tree('check', unchecknodes[i].target);
            }
        }
        if (checknodes && checknodes.length > 0) {
            for ( var i = 0; i < checknodes.length; i++) {
                resourceTree.tree('uncheck', checknodes[i].target);
            }
        }
    }
</script>


            <form id="insForm" method="post">
                <input id="eqtypeidadd" name="eqtypeid" type="hidden" value="${eqtypeid}" readonly="readonly">
                <input id="eqorgidadd" name="eqorgid"  type="hidden" value="${eqorgid}" readonly="readonly">
                <input id="departmentidadd" name="departmentid" type="hidden" value="${departmentid}" readonly="readonly">
                <table id="insfromgridadd"></table>
                <input id="resourceIds" name="resourceIds" type="hidden" />
            </form>


